<template>
	<view>
		<view class="lb-main-32">
			<div class="top-info">
				<div>待提现 <text class="price">￥{{infos.wait}}</text></div>
				<div>已提现 <text class="price">￥{{infos.cash}}</text></div>
			</div>
			<u-empty v-if="listData.length < 1" mode="data" text="暂无数据" icon="/static/empty/data.png"></u-empty>
			<view class="lb-list" v-for="(item,index) in listData" :key="index">
				<view class="lb-item">
					<view class="item-top">
						<view class="lb-left">
							<u-avatar :src="getImgUrl(item.avatar)" size="80rpx"></u-avatar>
						</view>
						<view class="lb-right">
							<view class="lb-name">
								{{item.contact}} <text>{{item.mobile}}</text>
							</view>
							<view class="lb-time">
								{{item.pay_time}}
							</view>
						</view>
					</view>
					<view class="item-foot">
						<view class="foot-box">
							订单号：{{item.order_number}}
						</view>
						<view class="foot-box">
							订单金额：￥{{item.price}}
						</view>
						<view class="foot-box">
							佣金：￥{{item.brokerage}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		popularizeInfo
	} from "@/api/apis/retail.js"
	import {
		setImgUrl
	} from "@/utils/comm.js"
	export default {
		data() {
			return {
				data: '',
				page: 1,
				limit: 10,
				listData: [],
				isLoading: false,
				infos: {}
			}
		},
		methods: {
			getImgUrl(url) {
				return setImgUrl(url);
			},
			getData() {
				uni.showLoading({
					title: '请求中',
					mask: true
				});
				this.isLoading = true;
				popularizeInfo({
					page: this.page,
					limit: this.limit,
				}).then(res => {
					uni.hideLoading();
					if (res.code == 1) {
						let order = res.data.orders
						this.infos = res.data
						if (this.page == 1) {
							this.listData = order.data;
						} else {
							this.listData = this.listData.concat(order.data);
						}
						if (order.total > this.page * this.limit) {
							this.isLoading = false;
							this.page++;
						}
					}

				})
			}
		},
		onReachBottom() {
			//注意 这里是重要的一步，不满足条件下拉加载不能继续请求数据
			if (!this.isLoading) {
				this.getData();
			}
		},
		onShow() {
			this.getData();
		}
	}
</script>

<style lang="scss">
	.top-info {
		display: flex;
		justify-content: space-around;
		margin-bottom: 30rpx;
		align-items: center;

		.price {
			display: inline-block;
			color: #F65D40;
			margin-left: 10rpx;
		}
	}

	//列表
	.lb-list {
		display: flex;
		background: rgba(255, 255, 255, 1);
		padding: 24rpx 0;
		border-radius: 16rpx;
		box-sizing: border-box;
		margin-bottom: 30rpx;


		.lb-item {
			width: 100%;
			display: flex;
			flex-direction: column;


			.item-top {
				display: flex;
				padding: 0 32rpx 24rpx;

				.lb-left {}

				.lb-right {
					display: flex;
					flex-direction: column;
					width: calc(100% - 80rpx);
					justify-content: space-between;
					padding-left: 24rpx;

					.lb-name {
						font-size: $main-font-28;
						color: $main-font-color;


						text {
							font-size: $main-font-24;
							color: $main-font-color-grey6;
							padding-left: 24rpx;
						}
					}

					.lb-time {
						font-size: $main-font-28;
						color: $main-font-color-grey9;
					}
				}

			}

			.item-foot {
				padding: 0 32rpx;

				.foot-box {
					margin-bottom: 10rpx;
					display: flex;
					align-items: center;
					font-size: $main-font-28;
					color: $main-font-color;
				}
			}
		}

	}
</style>